package com.hq.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hq.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class ProductController {
    @Resource
    private ProductService productService;
    @RequestMapping("list.do")
    public String list(Model model, @RequestParam(value = "cpage",defaultValue = "1")Integer cpage,
                       String mohu1){
        Map map = new HashMap();
        map.put("mohu1",mohu1);
        PageHelper.startPage(cpage,3);
        List list = productService.list(map);
        PageInfo pageInfo = new PageInfo(list);
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("map",map);
        return "list";
    }
}
